package baza.games.airSoccer;

import android.graphics.Canvas;
import android.graphics.Paint;

public class Paddle implements IDrawableComponent {

	float currX;
	float currY;
	float oldX;
	float oldY;
	int color;
	final float radio = 50;
	final float maxSpeed = 25;
	private AirSoccerEngine currEngine;
	PosicoesCampo posicaoCampo;
	
	
	public Paddle(int iX, int iY, int color, PosicoesCampo posicao)
	{
		this.currX = iX;
		this.currY = iY;
		this.color = color;
		this.posicaoCampo = posicao;
	}
	
	public void draw(Canvas canvas) {
		
		Paint paint = new Paint();
		paint.setColor(this.color);
		canvas.drawCircle(currX, currY, radio, paint);
		
	}

	public void update() {
		this.currEngine.colocaPaddlePosicaoValida(this);
	}

	public float getSpeedX()
	{
		return Math.min(maxSpeed, currX-oldX)* 1F;
	}
	
	public float getSpeedY()
	{
		return Math.min(maxSpeed, currY-oldY) * 1F;
	}
	
	public float getMass()
	{
		return radio/2;
	}

	public void SetPosition(float x, float y) {
		this.oldX = this.currX;
		this.oldY = this.currY;
		this.currX = x;
		this.currY = y;
	}

	public void setEngine(AirSoccerEngine engine) {
		this.currEngine = engine;
		
	}

}
